﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace CCSManager
{
    /// <summary>
    /// Interaction logic for Login.xaml
    /// </summary>
    public partial class Login : UserControl
    {
        public Login()
        {
            InitializeComponent();
        }

        public string UserName
        {
            get { return userNameTextBox.Text; }
        }

        public string Password
        {
            get { return passwordTextBox.Password; }
        }

        public event EventHandler LoggedIn;

        private void loginButton_Click(object sender, RoutedEventArgs e)
        {
            var creds = new CCS.CCSCredentials { UserName = userNameTextBox.Text, Password = passwordTextBox.Password };
            var ccsWebService = new CCS.CCS();
            if (ccsWebService.ValidateUser(creds))
            {
                if (LoggedIn != null)
                {
                    LoggedIn(this, new EventArgs());
                }
            }
        }
    }
}